package com.stxx.stiot2.controller;

import com.stxx.framwork.domain.R;
import com.stxx.framwork.domain.model.PageQuery;
import com.stxx.framwork.domain.model.PageResult;
import com.stxx.stiot2.domain.Signal;
import com.stxx.stiot2.service.SignalService;
import org.noear.solon.annotation.*;

import java.sql.SQLException;

@Controller
@Mapping("/signal")
public class SignalController {

    @Inject
    SignalService baseService;
    @Get
    @Mapping("/list")
    public PageResult<Signal> list(Signal bo, PageQuery pageQuery) throws SQLException {
        PageResult<Signal> r = baseService.pageList(bo,pageQuery);
        return r;
    }
    @Get
    @Mapping("/list-by-sw")
    public PageResult<Signal> listBySw(String sw, PageQuery pageQuery) throws SQLException {
        PageResult<Signal> r = baseService.listBySw(sw,pageQuery);
        return r;
    }



    @Post
    @Mapping("")
    public R<Object> add(@Body Signal bo) throws SQLException {
        baseService.insert(bo);
        return R.ok("数据保存成功");
    }

    @Put
    @Mapping("")
    public R<Object> edit(@Body Signal bo) throws SQLException {
        baseService.update(bo);
        return R.ok("数据保存成功");
    }

    @Delete
    @Mapping("/{ids}")
    public R<Object> remove(@Path String[] ids) throws SQLException {
        baseService.deleteByIds(ids);
        return R.ok("数据删除成功");
    }
}
